package com.controller.buyer;

import com.po.Buyerinfo;
import com.service.buyer.BuyerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/buyer")
public class BuyerLoginController {
 @Autowired
    private BuyerService buyerService;
    @RequestMapping("/register")
    public String register(@ModelAttribute Buyerinfo buser,Model model, HttpSession session, String code) {
        return buyerService.register(buser, model, session, code);
    }
    @RequestMapping("/login")
    public String login(@ModelAttribute Buyerinfo buyer, Model model, HttpSession session) {
        return buyerService.login(buyer, model, session);
    }
    @RequestMapping(value ="/exit")
    public String exit(@ModelAttribute Buyerinfo buyer,HttpSession session) {
        session.invalidate();
        return "buyer/login";
    }
}
